<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page contentType="text/html;charset=UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<link href="themes/css/ui.common.css" rel="stylesheet" type="text/css" />
		<link href="themes/css/ui.child.css" rel="stylesheet" type="text/css" />
		<link href="themes/css/ui.tips.css" rel="stylesheet" type="text/css" />
		<link href="style/jquery_ui/jquery-ui-1.8.custom.css" rel="stylesheet"
			type="text/css" />
		<link id="skin_css" rel="stylesheet" type="text/css"
			href="themes/css/ui.c.blue.css"></link>
		<link rel="stylesheet" href="themes/default/pagination.css"
			type="text/css"></link>
		<link rel="stylesheet" href="themes/css/ui.validation.css" type="text/css"></link>
		<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
		<script src="Scripts/jquery-ui-1.8.custom.min.js"
			type="text/javascript"></script>
		<script src="Scripts/ui.tips.js" type="text/javascript"></script>
		<script src="Scripts/ui.default.js " type="text/javascript"
			charset="UTF-8"></script>
		<script src="Scripts/ui.admincp.js" type="text/javascript"
			charset="UTF-8"></script>
		<script type="text/javascript" src="Scripts/jquery.json-2.2.min.js"></script>
		<STYLE type="text/css">
		.editorArea {
			display: none;
		}
		</STYLE>
		<script type="text/javascript" src="Scripts/ui.dialogFormHelper.js"></script>
		<script type="text/javascript" src="Scripts/ui.validation.js"></script>
		<SCRIPT type="text/javascript">
		$(function(){
            buttonClick();
		});
		
		function buttonClick() {
		    $("#btn_Average").click(function () {
		    	$("#btn_Average").attr("disabled", true);
		        var grade = $("#search_txt_grade").val();
		        var majorId = $("#search_dl_majorId").val();
		        var classNum = $("#txt_classNum").val();
		        if(grade =="" || majorId == "" || classNum == ""){
		        	alert("分班操作时，年级、专业和班级个数不能为空。");
		        	$("#btn_Average").attr("disabled", false);
		        	return false;
		        }
		        $.post("studentInfo!distributeByAverage.action", {"grade": grade,"majorId":majorId,"classNum":classNum}, function (data) {
		        	if(data == "-1"){
		        		alert("无人员需要分班处理。");
		        		$("#btn_Average").attr("disabled", false);
		        	}
		        	if(data == "1"){
		        		alert("分班成功！");
		        		$("#btn_Average").attr("disabled", false);
		        	}
		        	
		        });
		    });
		}
		</script>
		<SCRIPT type="text/javascript">
             var searching = false;
             $(function(){
             $("#link_page_prev,#link_page_next").click(function(){
			    var currentPage = $(this).attr("currentPage");
			    goToPage(currentPage);
			 }); 
			    	
			 $("#searchButton").click(function(){
                searching=true;
			    goToPage(1);
			 });
			    	
			 initSearch();
			    	 
             });
                  
             function initSearch(){
               $("#search_txt_stuNo").val();
               $("#search_txt_stuName").val();
               $("#search_dl_gender").val();
               $("#search_dl_majorId").val();
               $("#search_txt_grade").val();
               $("#search_txt_classNo").val();
               $("#search_drl_states").val();
             }
			 
             function goToPage(currentPage){
               var stuNo = $("#search_txt_stuNo").val();
               var stuName = $("#search_txt_stuName").val();
               var gender = $("#search_dl_gender").val();
               var majorId = $("#search_dl_majorId").val();
               var grade = $("#search_txt_grade").val();
               var classNo = $("#search_txt_classNo").val();
               var states = $("#search_drl_states").val();
                  	
               location.href = "studentInfo!queryStudentForDistribute.action?currpage="+currentPage+"&stuNo="+stuNo+"&stuName="+stuName+"&gender="+gender+"&majorId="+majorId+"&classNo="+classNo+"&states="+states+"&grade="+grade;
                  
             }
		</SCRIPT>
	</head>
	<body>
		<div class="PageChild_Title">
			<img src=" themes/images/default/icons/archives.png"
                  class="PageChild_Tbtnpic" />
			<span class="PageChild_separate"></span>
			<span class="PageChild_TbtnText"><h2>
					学生分班管理
				</h2>
			</span>
			<span class="PageChild_separate"></span>
			<div id="marker" class="red-tips">
			</div>
			<div class="clear">
			</div>
		</div>
		<div class="PageChild_Where">
			<table style="height: 60px;" border="0" cellpadding="0"
				cellspacing="0">
				<tr>
					<td align="left">
							&nbsp;学号:<input id="search_txt_stuNo" name="stuNo" type="text"  class="control-width-100 input-control" value="${stuNo}"/>
							&nbsp;姓名:<input id="search_txt_stuName" name="stuName" type="text"  class="control-width-100 input-control" value="${stuName}"/>
							&nbsp;性别:<s:select list="#{'男':'男','女':'女'}" headerKey="" headerValue="-所有-" id="search_dl_gender" name="gender" value="gender" theme="simple" cssClass="control-width-40 clearable" cssStyle="width: 152px; height: 26px"></s:select>
							&nbsp;专业:<s:select list="majorInfoList" listKey="majorId" listValue="majorName" headerKey="" headerValue="-请选择-" id="search_dl_majorId" name="majorId" theme="simple" cssClass="selectable-field control-width-40 clearable" cssStyle="width: 152px; height: 26px"></s:select><br/>
							&nbsp;年级:<input id="search_txt_grade" name="grade" type="text"  class="control-width-100 input-control" value="${grade}"/>
							&nbsp;班级:<input id="search_txt_classNo" name="classNo" type="text"  class="control-width-100 input-control" value="${classNo}"/>
							&nbsp;状态:<s:select list="#{0:'准备分班',1:'已分班'}"  headerKey="" headerValue="-所有-" id="search_drl_states" theme="simple" cssClass="clearable" value="states"></s:select>
					</td>
					<td class="mtd">
							&nbsp;
							<input type="button" id="searchButton"
							class="o-btn SubmitButton" value="搜 索" onclick='goToPage(1)'/>
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<br/>
						<span id="lbl_list_count">共搜索到 <b>${count}</b> 条符合条件的记录。</span>
					</td>
				</tr>
			</table>
		</div>
		<div class="PageChild_List">
			<table width="100%" border="0" cellspacing="0"
				style="text-align: left">
				<tbody class="PageChild_List_head">
					<tr>
						<td width="16">
							<img src="themes/images/default/icons/pcde_314.png" width="16"
								height="16" />
						</td>
						<td>
							学号
						</td>
						<td>
							姓名
						</td>
						<td>
							性别
						</td>
						<td>
							专业
						</td>
						<td>
							年级
						</td>
						<td>
							班级
						</td>
						<td>
							分数
						</td>
						<td>
							状态
						</td>
					</tr>
				</tbody>
				<tbody class="PageChild_List_main" style="text-align: left">
					<s:if test="stuList != null && stuList.size != 0">
					<s:iterator value="stuList" var="item" status="no">
						<tr class='td_no_bord'>
							<td class="td_width25">
								<s:property value="#no.count" />
							</td>
							<td>
								${item.stuNo} &nbsp;
							</td>
							<td>
								${item.stuName} &nbsp;
							</td>
							<td>
								${item.stuDetail.gender} &nbsp;
							</td>
							<td>
								${item.stuDetail.majorInfo.majorName} &nbsp;
							</td>
							<td>
								${item.stuDetail.grade} &nbsp;
							</td>
							<td>
								${item.stuDetail.classNo} &nbsp;
							</td>
							<td>
								${item.stuDetail.scoreInfo.sumScore} &nbsp;
							</td>
							<td>
								<s:if test="#item.states==0">准备分班</s:if>
								<s:if test="#item.states>=1">已分班</s:if>
							</td>
						</tr>
					</s:iterator>
					</s:if><s:else>
						<tr><td colspan="9">无记录</td></tr>
					</s:else>
				</tbody>
			</table>
		</div>
		<!--分页导航开始-->
		<div id="divTopPageNavi" class="list_r_title_text3">
		<input class="hiddenObject" value="${currpage }" id="currentPage">
			<s:if test="currpage<=1">
				<span class='list_r_title_text3a'> <img
						src=" themes/images/default/page_up_gray.gif"></img> </span>

			</s:if>
			<s:else>
				<span class='list_r_title_text3a'> <a name="link_page_prev"
					id="link_page_prev" href="javascript:void(0);"
					currentPage="${currpage-1}"> <img
							src=" themes/images/default/page_up.gif"></img> </a> </span>
			</s:else>
			<span class='list_r_title_text3b'> 第${currpage }页/共${totalpage}页 </span>
			<s:if test="currpage>=totalpage">
				<span class='list_r_title_text3a'> <img
						src=" themes/images/default/page_down_gray.gif"></img> </span>
			</s:if>
			<s:else>
				<span class='list_r_title_text3a'> <a name="link_page_next"
					id="link_page_next" href="javascript:void(0);"
					currentPage="${currpage+1 }"> <img
							src=" themes/images/default/page_down.gif"></img> </a> </span>
			</s:else>
			<span id="goToPageTextArea"><input type="text"
					class="easyui-numberbox" id="goPageNum" max="${totalpage}" min="1" />
				<input type="button" id="turnToPageButton" value="GO" />
			</span>
		</div>
		<!--分页导航结束-->
		<div>
			班级个数：<input type="text" id="txt_classNum"> <input type="button" id="btn_Average" class="o-btn" value="随机分班">
		</div>
	</body>
</html>